```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>分布式与微服务架构深入解析 | 技术小馆</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            line-height: 1.8;
            color: #333;
            background-color: #f9fafb;
        }
        h1, h2, h3, h4 {
            font-family: 'Noto Serif SC', serif;
            font-weight: 700;
        }
        .hero-bg {
            background: linear-gradient(135deg, #6e8efb 0%, #a777e3 100%);
        }
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
        }
        .feature-icon {
            width: 60px;
            height: 60px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            margin-bottom: 1.5rem;
        }
        .timeline-item::before {
            content: '';
            position: absolute;
            left: -1.5rem;
            top: 0;
            height: 100%;
            width: 2px;
            background-color: #e0e6ed;
        }
        .timeline-dot {
            position: absolute;
            left: -1.85rem;
            top: 0.5rem;
            width: 1rem;
            height: 1rem;
            border-radius: 50%;
            border: 2px solid #4f46e5;
            background-color: white;
        }
        .comparison-card {
            transition: all 0.3s ease;
        }
        .comparison-card:hover {
            transform: scale(1.02);
        }
    </style>
</head>
<body class="antialiased">
    <!-- Hero Section -->
    <section class="hero-bg text-white py-20 px-4 md:px-0">
        <div class="container mx-auto max-w-6xl px-4">
            <div class="flex flex-col md:flex-row items-center">
                <div class="md:w-1/2 mb-10 md:mb-0">
                    <h1 class="text-4xl md:text-5xl font-bold mb-6 leading-tight">分布式与微服务架构解析</h1>
                    <p class="text-xl mb-8 text-blue-100">探索现代软件架构的核心概念、设计原则与实践经验</p>
                    <div class="flex flex-wrap gap-4">
                        <a href="#microservices" class="bg-white text-indigo-600 px-6 py-3 rounded-lg font-medium hover:bg-indigo-50 transition duration-300">
                            <i class="fas fa-cubes mr-2"></i>微服务架构
                        </a>
                        <a href="#distributed" class="bg-indigo-600 bg-opacity-20 text-white px-6 py-3 rounded-lg font-medium hover:bg-opacity-30 transition duration-300">
                            <i class="fas fa-network-wired mr-2"></i>分布式系统
                        </a>
                    </div>
                </div>
                <div class="md:w-1/2">
                    <div class="relative">
                        <div class="absolute -top-10 -left-10 w-32 h-32 bg-yellow-400 rounded-full opacity-20"></div>
                        <div class="absolute -bottom-5 -right-5 w-32 h-32 bg-purple-400 rounded-full opacity-20"></div>
                        <div class="relative bg-white bg-opacity-10 backdrop-filter backdrop-blur-lg rounded-2xl p-6 border border-white border-opacity-20 shadow-xl">
                            <div class="mermaid">
                                graph TD
                                    A[客户端] --> B[API网关]
                                    B --> C[用户服务]
                                    B --> D[订单服务]
                                    B --> E[支付服务]
                                    C --> F[(用户数据库)]
                                    D --> G[(订单数据库)]
                                    E --> H[(支付数据库)]
                                    C -.->|消息队列| D
                                    D -.->|消息队列| E
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Introduction Section -->
    <section class="py-16 px-4 bg-white">
        <div class="container mx-auto max-w-6xl">
            <div class="text-center mb-16">
                <h2 class="text-3xl font-bold mb-4 text-gray-800">现代软件架构演进</h2>
                <div class="w-24 h-1 bg-indigo-500 mx-auto"></div>
            </div>
            
            <div class="flex flex-col md:flex-row gap-8 mb-16">
                <div class="md:w-1/2">
                    <p class="text-lg text-gray-700 mb-6">
                        在当今互联网时代，软件系统的复杂性和用户需求的多样性不断增加，这使得传统的单体应用架构面临了很多挑战。为了更好地满足这些挑战，软件架构从传统的单体应用架构逐渐演变为分布式系统和微服务架构。
                    </p>
                    <div class="bg-gray-50 p-6 rounded-lg border-l-4 border-indigo-500">
                        <p class="text-gray-700 italic">
                            "微服务架构是分布式系统的一种特殊实现方式，它将应用程序拆分为一组小型、自治的服务，每个服务专注于一个特定的业务功能。"
                        </p>
                    </div>
                </div>
                <div class="md:w-1/2">
                    <img src="https://cdn.nlark.com/yuque/0/2024/png/21449790/1718715772277-cee3c2f0-8bba-495e-b153-501bcde795fb.png" alt="架构演进" class="rounded-lg shadow-md w-full">
                </div>
            </div>
            
            <!-- Comparison Section -->
            <div class="grid grid-cols-1 md:grid-cols-2 gap-8">
                <div id="microservices" class="comparison-card bg-white p-6 rounded-xl shadow-md border-t-4 border-blue-500">
                    <div class="flex items-center mb-4">
                        <div class="feature-icon bg-blue-100 text-blue-600">
                            <i class="fas fa-cubes text-2xl"></i>
                        </div>
                        <h3 class="text-2xl font-bold ml-4 text-gray-800">微服务架构</h3>
                    </div>
                    <p class="text-gray-700 mb-4">
                        微服务架构是一种通过将应用程序拆分为多个小型、独立的服务来构建应用的方法，每个服务运行在自己的进程中，通过轻量级通信进行互操作。
                    </p>
                    <div class="mb-4">
                        <img src="https://cdn.nlark.com/yuque/0/2024/png/21449790/1718715598080-4905622e-47f2-42a3-92be-df3786fc744f.png" alt="微服务架构" class="rounded-lg w-full">
                    </div>
                    <div class="bg-blue-50 p-4 rounded-lg">
                        <h4 class="font-semibold text-blue-800 mb-2"><i class="fas fa-film mr-2"></i>在线电影订票平台示例</h4>
                        <ul class="text-gray-700 space-y-2">
                            <li><i class="fas fa-check-circle text-blue-500 mr-2"></i>独立服务：用户管理、电影信息、订票、支付等</li>
                            <li><i class="fas fa-check-circle text-blue-500 mr-2"></i>服务边界清晰，职责单一</li>
                            <li><i class="fas fa-check-circle text-blue-500 mr-2"></i>可独立扩展和部署</li>
                        </ul>
                    </div>
                </div>
                
                <div id="distributed" class="comparison-card bg-white p-6 rounded-xl shadow-md border-t-4 border-purple-500">
                    <div class="flex items-center mb-4">
                        <div class="feature-icon bg-purple-100 text-purple-600">
                            <i class="fas fa-network-wired text-2xl"></i>
                        </div>
                        <h3 class="text-2xl font-bold ml-4 text-gray-800">分布式系统</h3>
                    </div>
                    <p class="text-gray-700 mb-4">
                        分布式系统是由多台计算机组成的系统，这些计算机通过网络连接在一起，协同工作以完成一个任务或提供一个服务。
                    </p>
                    <div class="mb-4">
                        <img src="https://cdn.nlark.com/yuque/0/2024/png/21449790/1718715640500-5341c600-4020-47b0-8cf4-034d0380b70c.png" alt="分布式系统" class="rounded-lg w-full">
                    </div>
                    <div class="bg-purple-50 p-4 rounded-lg">
                        <h4 class="font-semibold text-purple-800 mb-2"><i class="fas fa-university mr-2"></i>全国银行网点系统示例</h4>
                        <ul class="text-gray-700 space-y-2">
                            <li><i class="fas fa-check-circle text-purple-500 mr-2"></i>分布式节点：全国各分支机构</li>
                            <li><i class="fas fa-check-circle text-purple-500 mr-2"></i>数据分布在各地，提高可用性</li>
                            <li><i class="fas fa-check-circle text-purple-500 mr-2"></i>容错能力强，单点故障不影响整体</li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Microservices Deep Dive -->
    <section class="py-16 px-4 bg-gray-50">
        <div class="container mx-auto max-w-6xl">
            <div class="text-center mb-16">
                <h2 class="text-3xl font-bold mb-4 text-gray-800">微服务架构深入解析</h2>
                <p class="text-xl text-gray-600 max-w-3xl mx-auto">通过七大核心原则构建灵活可扩展的系统架构</p>
                <div class="w-24 h-1 bg-indigo-500 mx-auto mt-4"></div>
            </div>
            
            <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8 mb-12">
                <!-- Principle 1 -->
                <div class="bg-white p-6 rounded-xl shadow-sm border border-gray-100 card-hover transition duration-300">
                    <div class="text-indigo-600 mb-4">
                        <i class="fas fa-object-ungroup text-3xl"></i>
                    </div>
                    <h3 class="text-xl font-bold mb-3 text-gray-800">1. 服务拆分</h3>
                    <p class="text-gray-700">
                        将整个应用程序拆分为多个小型、自治的服务，每个微服务专注于一个明确定义的业务功能或领域。
                    </p>
                    <div class="mt-4 pt-4 border-t border-gray-100">
                        <h4 class="text-sm font-semibold text-gray-500 mb-2">关键点</h4>
                        <ul class="text-gray-600 text-sm space-y-1">
                            <li><i class="fas fa-circle text-xs mr-2 text-indigo-400"></i>业务边界的确定</li>
                            <li><i class="fas fa-circle text-xs mr-2 text-indigo-400"></i>解耦和高内聚</li>
                            <li><i class="fas fa-circle text-xs mr-2 text-indigo-400"></i>服务粒度的选择</li>
                        </ul>
                    </div>
                </div>
                
                <!-- Principle 2 -->
                <div class="bg-white p-6 rounded-xl shadow-sm border border-gray-100 card-hover transition duration-300">
                    <div class="text-indigo-600 mb-4">
                        <i class="fas fa-crown text-3xl"></i>
                    </div>
                    <h3 class="text-xl font-bold mb-3 text-gray-800">2. 自治性</h3>
                    <p class="text-gray-700">
                        每个微服务在技术上和组织上都应该是自治的，可以独立地开发、部署和扩展。
                    </p>
                    <div class="mt-4 pt-4 border-t border-gray-100">
                        <h4 class="text-sm font-semibold text-gray-500 mb-2">关键点</h4>
                        <ul class="text-gray-600 text-sm space-y-1">
                            <li><i class="fas fa-circle text-xs mr-2 text-indigo-400"></i>独立部署</li>
                            <li><i class="fas fa-circle text-xs mr-2 text-indigo-400"></i>技术栈的选择</li>
                            <li><i class="fas fa-circle text-xs mr-2 text-indigo-400"></i>自治的团队</li>
                        </ul>
                    </div>
                </div>
                
                <!-- Principle 3 -->
                <div class="bg-white p-6 rounded-xl shadow-sm border border-gray-100 card-hover transition duration-300">
                    <div class="text-indigo-600 mb-4">
                        <i class="fas fa-comments text-3xl"></i>
                    </div>
                    <h3 class="text-xl font-bold mb-3 text-gray-800">3. 轻量通信</h3>
                    <p class="text-gray-700">
                        微服务之间通过轻量级通信机制进行互操作，如RESTful API、消息队列或gRPC。
                    </p>
                    <div class="mt-4 pt-4 border-t border-gray-100">
                        <h4 class="text-sm font-semibold text-gray-500 mb-2">关键点</h4>
                        <ul class="text-gray-600 text-sm space-y-1">
                            <li><i class="fas fa-circle text-xs mr-2 text-indigo-400"></i>RESTful API</li>
                            <li><i class="fas fa-circle text-xs mr-2 text-indigo-400"></i>消息队列</li>
                            <li><i class="fas fa-circle text-xs mr-2 text-indigo-400"></i>gRPC</li>
                        </ul>
                    </div>
                </div>
                
                <!-- Principle 4 -->
                <div class="bg-white p-6 rounded-xl shadow-sm border border-gray-100 card-hover transition duration-300">
                    <div class="text-indigo-600 mb-4">
                        <i class="fas fa-database text-3xl"></i>
                    </div>
                    <h3 class="text-xl font-bold mb-3 text-gray-800">4. 分布式数据</h3>
                    <p class="text-gray-700">
                        每个微服务可以有自己的数据存储解决方案，通过事件驱动或异步机制共享数据。
                    </p>
                    <div class="mt-4 pt-4 border-t border-gray-100">
                        <h4 class="text-sm font-semibold text-gray-500 mb-2">关键点</h4>
                        <ul class="text-gray-600 text-sm space-y-1">
                            <li><i class="fas fa-circle text-xs mr-2 text-indigo-400"></i>数据库选择</li>
                            <li><i class="fas fa-circle text-xs mr-2 text-indigo-400"></i>数据一致性</li>
                            <li><i class="fas fa-circle text-xs mr-2 text-indigo-400"></i>事件驱动架构</li>
                        </ul>
                    </div>
                </div>
                
                <!-- Principle 5 -->
                <div class="bg-white p-6 rounded-xl shadow-sm border border-gray-100 card-hover transition duration-300">
                    <div class="text-indigo-600 mb-4">
                        <i class="fas fa-address-book text-3xl"></i>
                    </div>
                    <h3 class="text-xl font-bold mb-3 text-gray-800">5. 注册中心</h3>
                    <p class="text-gray-700">
                        管理和维护所有微服务的注册信息，实现服务发现与动态调用。
                    </p>
                    <div class="mt-4 pt-4 border-t border-gray-100">
                        <h4 class="text-sm font-semibold text-gray-500 mb-2">关键点</h4>
                        <ul class="text-gray-600 text-sm space-y-1">
                            <li><i class="fas fa-circle text-xs mr-2 text-indigo-400"></i>服务注册</li>
                            <li><i class="fas fa-circle text-xs mr-2 text-indigo-400"></i>服务发现</li>
                            <li><i class="fas fa-circle text-xs mr-2 text-indigo-400"></i>健康检查</li>
                        </ul>
                    </div>
                </div>
                
                <!-- Principle 6 -->
                <div class="bg-white p-6 rounded-xl shadow-sm border border-gray-100 card-hover transition duration-300">
                    <div class="text-indigo-600 mb-4">
                        <i class="fas fa-shield-alt text-3xl"></i>
                    </div>
                    <h3 class="text-xl font-bold mb-3 text-gray-800">6. 熔断降级</h3>
                    <p class="text-gray-700">
                        防止故障蔓延和提高系统可用性的容错机制。
                    </p>
                    <div class="mt-4 pt-4 border-t border-gray-100">
                        <h4 class="text-sm font-semibold text-gray-500 mb-2">关键点</h4>
                        <ul class="text-gray-600 text-sm space-y-1">
                            <li><i class="fas fa-circle text-xs mr-2 text-indigo-400"></i>熔断器(Circuit Breaker)</li>
                            <li><i class="fas fa-circle text-xs mr-2 text-indigo-400"></i>降级(Fallback)</li>
                            <li><i class="fas fa-circle text-xs mr-2 text-indigo-400"></i>限流保护</li>
                        </ul>
                    </div>
                </div>
                
                <!-- Principle 7 -->
                <div class="bg-white p-6 rounded-xl shadow-sm border border-gray-100 card-hover transition duration-300">
                    <div class="text-indigo-600 mb-4">
                        <i class="fas fa-door-open text-3xl"></i>
                    </div>
                    <h3 class="text-xl font-bold mb-3 text-gray-800">7. 路由网关</h3>
                    <p class="text-gray-700">
                        所有微服务的前端门面，统一管理和处理客户端请求。
                    </p>
                    <div class="mt-4 pt-4 border-t border-gray-100">
                        <h4 class="text-sm font-semibold text-gray-500 mb-2">关键点</h4>
                        <ul class="text-gray-600 text-sm space-y-1">
                            <li><i class="fas fa-circle text-xs mr-2 text-indigo-400"></i>请求路由</li>
                            <li><i class="fas fa-circle text-xs mr-2 text-indigo-400"></i>负载均衡</li>
                            <li><i class="fas fa-circle text-xs mr-2 text-indigo-400"></i>安全认证</li>
                        </ul>
                    </div>
                </div>
            </div>
            
            <!-- Advantages Section -->
            <div class="bg-white rounded-xl shadow-md overflow-hidden mb-12">
                <div class="p-8">
                    <h3 class="text-2xl font-bold mb-6 text-gray-800">微服务架构的优势</h3>
                    <div class="grid grid-cols-1 md:grid-cols-2 gap-8">
                        <div>
                            <div class="flex items-start mb-4">
                                <div class="bg-green-100 p-3 rounded-full mr-4">
                                    <i class="fas fa-leaf text-green-600 text-xl"></i>
                                </div>
                                <div>
                                    <h4 class="text-lg font-semibold text-gray-800 mb-2">灵活性和可维护性</h4>
                                    <p class="text-gray-700">
                                        每个微服务可以独立开发、部署和扩展，团队可以根据业务需求独立迭代和发布服务。
                                    </p>
                                </div>
                            </div>
                            
                            <div class="flex items-start mb-4">
                                <div class="bg-blue-100 p-3 rounded-full mr-4">
                                    <i class="fas fa-puzzle-piece text-blue-600 text-xl"></i>
                                </div>
                                <div>
                                    <h4 class="text-lg font-semibold text-gray-800 mb-2">技术多样性</h4>
                                    <p class="text-gray-700">
                                        不同的微服务可以使用不同的编程语言、框架和数据存储技术，以最大化解决方案的灵活性和性能。
                                    </p>
                                </div>
                            </div>
                        </div>
                        
                        <div>
                            <div class="flex items-start mb-4">
                                <div class="bg-purple-100 p-3 rounded-full mr-4">
                                    <i class="fas fa-expand-arrows-alt text-purple-600 text-xl"></i>
                                </div>
                                <div>
                                    <h4 class="text-lg font-semibold text-gray-800 mb-2">可伸缩性</h4>
                                    <p class="text-gray-700">
                                        每个微服务可以根据负载和性能需求独立扩展，而不是整体扩展整个应用。
                                    </p>
                                </div>
                            </div>
                            
                            <div class="flex items-start">
                                <div class="bg-yellow-100 p-3 rounded-full mr-4">
                                    <i class="fas fa-bolt text-yellow-600 text-xl"></i>
                                </div>
                                <div>
                                    <h4 class="text-lg font-semibold text-gray-800 mb-2">快速创新</h4>
                                    <p class="text-gray-700">
                                        小团队可以独立工作，减少了开发人员之间的协调和依赖，提高了团队的生产力和创新能力。
                                    </p>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="bg-gray-50 px-8 py-4 border-t border-gray-100">
                    <h4 class="text-lg font-semibold text-gray-800 mb-2">适用场景</h4>
                    <div class="flex flex-wrap gap-2">
                        <span class="px-3 py-1 bg-indigo-100 text-indigo-800 rounded-full text-sm">大型复杂系统</span>
                        <span class="px-3 py-1 bg-indigo-100 text-indigo-800 rounded-full text-sm">快速迭代需求</span>
                        <span class="px-3 py-1 bg-indigo-100 text-indigo-800 rounded-full text-sm">高可用性要求</span>
                        <span class="px-3 py-1 bg-indigo-100 text-indigo-800 rounded-full text-sm">多团队协作</span>
                        <span class="px-3 py-1 bg-indigo-100 text-indigo-800 rounded-full text-sm">快速增长业务</span>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Distributed Systems Section -->
    <section class="py-16 px-4 bg-white">
        <div class="container mx-auto max-w-6xl">
            <div class="text-center mb-16">
                <h2 class="text-3xl font-bold mb-4 text-gray-800">分布式系统核心问题</h2>
                <p class="text-xl text-gray-600 max-w-3xl mx-auto">构建稳定可靠分布式系统的关键挑战与解决方案</p>
                <div class="w-24 h-1 bg-indigo-500 mx-auto mt-4"></div>
            </div>
            
            <!-- CAP Theorem -->
            <div class="mb-16">
                <div class="flex items-center mb-8">
                    <div class="bg-red-500 text-white p-3 rounded-lg mr-4">
                        <i class="fas fa-exclamation-triangle text-2xl"></i>
                    </div>
                    <h3 class="text-2xl font-bold text-gray-800">CAP定理</h3>
                </div>
                
                <div class="flex flex-col md:flex-row gap-8">
                    <div class="md:w-1/2">
                        <p class="text-gray-700 mb-6">
                            CAP定理指出，一个分布式系统不可能同时满足一致性(Consistency)、可用性(Availability)和分区容错性(Partition Tolerance)这三个特性，最多只能同时满足其中的两个。
                        </p>
                        
                        <div class="bg-gray-50 p-6 rounded-lg mb-6">
                            <div class="mermaid">
                                graph LR
                                    A[CAP定理] --> B[一致性]
                                    A --> C[可用性]
                                    A --> D[分区容错性]
                                    style B fill:#f9c0c0,stroke:#f66
                                    style C fill:#c0e4f9,stroke:#66c
                                    style D fill:#d4f9c0,stroke:#6c6
                            </div>
                        </div>
                    </div>
                    
                    <div class="md:w-1/2">
                        <div class="bg-white border border-gray-200 rounded-lg shadow-sm overflow-hidden">
                            <div class="bg-gray-800 text-white px-4 py-3">
                                <h4 class="font-semibold">选择策略</h4>
                            </div>
                            <div class="p-4">
                                <div class="mb-4">
                                    <h5 class="font-medium text-gray-800 mb-2">CP系统（一致性与分区容错性）</h5>
                                    <p class="text-gray-700 text-sm">
                                        牺牲可用性，确保数据一致性和分区容错性。适用于金融、支付等对数据一致性要求极高的场景。
                                    </p>
                                </div>
                                <div class="mb-4">
                                    <h5 class="font-medium text-gray-800 mb-2">AP系统（可用性与分区容错性）</h5>
                                    <p class="text-gray-700 text-sm">
                                        牺牲一致性，确保高可用性和分区容错性。适用于社交网络、内容分发等场景。
                                    </p>
                                </div>
                                <div>
                                    <h5 class="font-medium text-gray-800 mb-2">CA系统（一致性与可用性）</h5>
                                    <p class="text-gray-700 text-sm">
                                        牺牲分区容错性，通常只适合单机系统或局域网环境，不适合真正的分布式系统。
                                    </p>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            
            <!-- Distributed Problems -->
            <div class="grid grid-cols-1 md:grid-cols-3 gap-8 mb-12">
                <!-- Consistency -->
                <div class="bg-white p-6 rounded-xl shadow-sm border border-gray-100 card-hover">
                    <div class="flex items-center mb-4">
                        <div class="bg-blue-100 p-3 rounded-lg mr-4 text-blue-600">
                            <i class="fas fa-balance-scale text-xl"></i>
                        </div>
                        <h3 class="text-xl font-bold text-gray-800">一致性问题</h3>
                    </div>
                    <p class="text-gray-700 mb-4">
                        多个副本之间数据的一致性保证，在数据更新过程中保持所有相关副本一致。
                    </p>
                    <div class="bg-blue-50 p-4 rounded-lg">
                        <h4 class="font-semibold text-blue-800 mb-2">解决方案</h4>
                        <ul class="text-gray-700 text-sm space-y-2">
                            <li><i class="fas fa-check text-blue-500 mr-2"></i>强一致性：两阶段提交</li>
                            <li><i class="fas fa-check text-blue-500 mr-2"></i>弱一致性：最终一致性</li>
                            <li><i class="fas fa-check text-blue-500 mr-2"></i>复制日志（Paxos/Raft）</li>
                        </ul>
                    </div>
                </div>
                
                <!-- Availability -->
                <div class="bg-white p-6 rounded-xl shadow-sm border border-gray-100 card-hover">
                    <div class="flex items-center mb-4">
                        <div class="bg-green-100 p-3 rounded-lg mr-4 text-green-600">
                            <i class="fas fa-check-circle text-xl"></i>
                        </div>
                        <h3 class="text-xl font-bold text-gray-800">可用性问题</h3>
                    </div>
                    <p class="text-gray-700 mb-4">
                        系统能够在正常工作和响应请求的情况下持续运行的能力。
                    </p>
                    <div class="bg-green-50 p-4 rounded-lg">
                        <h4 class="font-semibold text-green-800 mb-2">解决方案</h4>
                        <ul class="text-gray-700 text-sm space-y-2">
                            <li><i class="fas fa-check text-green-500 mr-2"></i>故障转移和容错</li>
                            <li><i class="fas fa-check text-green-500 mr-2"></i>负载均衡</li>
                            <li><i class="fas fa-check text-green-500 mr-2"></i>可恢复性设计</li>
                        </ul>
                    </div>
                </div>
                
                <!-- Partition Tolerance -->
                <div class="bg-white p-6 rounded-xl shadow-sm border border-gray-100 card-hover">
                    <div class="flex items-center mb-4">
                        <div class="bg-purple-100 p-3 rounded-lg mr-4 text-purple-600">
                            <i class="fas fa-shield-alt text-xl"></i>
                        </div>
                        <h3 class="text-xl font-bold text-gray-800">分区容错性</h3>
                    </div>
                    <p class="text-gray-700 mb-4">
                        系统在面对网络分区时，仍然能够继续工作和提供服务的能力。
                    </p>
                    <div class="bg-purple-50 p-4 rounded-lg">
                        <h4 class="font-semibold text-purple-800 mb-2">解决方案</h4>
                        <ul class="text-gray-700 text-sm space-y-2">
                            <li><i class="fas fa-check text-purple-500 mr-2"></i>数据分片</li>
                            <li><i class="fas fa-check text-purple-500 mr-2"></i>容错算法</li>
                            <li><i class="fas fa-check text-purple-500 mr-2"></i>多副本机制</li>
                        </ul>
                    </div>
                </div>
            </div>
            
            <!-- Communication Methods -->
            <div class="mb-12">
                <h3 class="text-2xl font-bold mb-6 text-gray-800">分布式系统通信方式</h3>
                
                <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                    <!-- RPC -->
                    <div class="bg-white p-6 rounded-xl shadow-sm border border-gray-100">
                        <div class="flex items-center mb-4">
                            <div class="bg-orange-100 p-3 rounded-lg mr-4 text-orange-600">
                                <i class="fas fa-exchange-alt text-xl"></i>
                            </div>
                            <h4 class="text-xl font-bold text-gray-800">远程过程调用(RPC)</h4>
                        </div>
                        <p class="text-gray-700 mb-4">
                            允许一个程序调用另一个程序中的函数或方法，通过网络在不同节点之间进行通信。
                        </p>
                        <div class="flex flex-wrap gap-2">
                            <span class="px-3 py-1 bg-orange-100 text-orange-800 rounded-full text-sm">gRPC</span>
                            <span class="px-3 py-1 bg-orange-100 text-orange-800 rounded-full text-sm">Thrift</span>
                            <span class="px-3 py-1 bg-orange-100 text-orange-800 rounded-full text-sm">Dubbo</span>
                        </div>
                    </div>
                    
                    <!-- Message Queue -->
                    <div class="bg-white p-6 rounded-xl shadow-sm border border-gray-100">
                        <div class="flex items-center mb-4">
                            <div class="bg-pink-100 p-3 rounded-lg mr-4 text-pink-600">
                                <i class="fas fa-inbox text-xl"></i>
                            </div>
                            <h4 class="text-xl font-bold text-gray-800">消息队列</h4>
                        </div>
                        <p class="text-gray-700 mb-4">
                            通过异步消息传递在分布式系统中进行通信，解耦发送者和接收者之间的关系。
                        </p>
                        <div class="flex flex-wrap gap-2">
                            <span class="px-3 py-1 bg-pink-100 text-pink-800 rounded-full text-sm">Kafka</span>
                            <span class="px-3 py-1 bg-pink-100 text-pink-800 rounded-full text-sm">RabbitMQ</span>
                            <span class="px-3 py-1 bg-pink-100 text-pink-800 rounded-full text-sm">RocketMQ</span>
                        </div>
                    </div>
                    
                    <!-- DB Replication -->
                    <div class="bg-white p-6 rounded-xl shadow-sm border border-gray-100">
                        <div class="flex items-center mb-4">
                            <div class="bg-teal-100 p-3 rounded-lg mr-4 text-teal-600">
                                <i class="fas fa-copy text-xl"></i>
                            </div>
                            <h4 class="text-xl font-bold text-gray-800">数据库复制</h4>
                        </div>
                        <p class="text-gray-700 mb-4">
                            将数据库的更新操作异步或同步地复制到多个节点，实现数据的多副本存储。
                        </p>
                        <div class="flex flex-wrap gap-2">
                            <span class="px-3 py-1 bg-teal-100 text-teal-800 rounded-full text-sm">主从复制</span>
                            <span class="px-3 py-1 bg-teal-100 text-teal-800 rounded-full text-sm">多主复制</span>
                            <span class="px-3 py-1 bg-teal-100 text-teal-800 rounded-full text-sm">分片复制</span>
                        </div>
                    </div>
                    
                    <!-- Distributed FS -->
                    <div class="bg-white p-6 rounded-xl shadow-sm border border-gray-100">
                        <div class="flex items-center mb-4">
                            <div class="bg-indigo-100 p-3 rounded-lg mr-4 text-indigo-600">
                                <i class="fas fa-folder-open text-xl"></i>
                            </div>
                            <h4 class="text-xl font-bold text-gray-800">分布式文件系统</h4>
                        </div>
                        <p class="text-gray-700 mb-4">
                            提供文件存储的分布式解决方案，支持多个节点同时访问和更新数据。
                        </p>
                        <div class="flex flex-wrap gap-2">
                            <span class="px-3 py-1 bg-indigo-100 text-indigo-800 rounded-full text-sm">HDFS</span>
                            <span class="px-3 py-1 bg-indigo-100 text-indigo-800 rounded-full text-sm">GFS</span>
                            <span class="px-3 py-1 bg-indigo-100 text-indigo-800 rounded-full text-sm">Ceph</span>
                        </div>
                    </div>
                </div>
            </div>
            
            <!-- Distributed Challenges -->
            <div>
                <h3 class="text-2xl font-bold mb-6 text-gray-800">分布式系统下的挑战</h3>
                
                <div class="grid grid-cols-1 md:grid-cols-3 gap-6">
                    <!-- Distributed Lock -->
                    <div class="bg-white p-6 rounded-xl shadow-sm border border-gray-100">
                        <div class="flex items-center mb-4">
                            <div class="bg-red-100 p-3 rounded-lg mr-4 text-red-600">
                                <i class="fas fa-lock text-xl"></i>
                            </div>
                            <h4 class="text-xl font-bold text-gray-800">分布式锁</h4>
                        </div>
                        <p class="text-gray-700 mb-4">
                            实现资源的并发访问控制，确保在分布式环境下资源的安全访问。
                        </p>
                        <ul class="text-gray-700 text-sm space-y-2">
                            <li><i class="fas fa-circle text-xs mr-2 text-red-400"></i>基于数据库</li>
                            <li><i class="fas fa-circle text-xs mr-2 text-red-400"></i>基于缓存（Redis）</li>
                            <li><i class="fas fa-circle text-xs mr-2 text-red-400"></i>基于ZooKeeper</li>
                        </ul>
                    </div>
                    
                    <!-- Distributed Tasks -->
                    <div class="bg-white p-6 rounded-xl shadow-sm border border-gray-100">
                        <div class="flex items-center mb-4">
                            <div class="bg-blue-100 p-3 rounded-lg mr-4 text-blue-600">
                                <i class="fas fa-tasks text-xl"></i>
                            </div>
                            <h4 class="text-xl font-bold text-gray-800">分布式任务</h4>
                        </div>
                        <p class="text-gray-700 mb-4">
                            在分布式环境下执行的工作单元或业务操作，需要有效的调度和管理。
                        </p>
                        <ul class="text-gray-700 text-sm space-y-2">
                            <li><i class="fas fa-circle text-xs mr-2 text-blue-400"></i>异步执行</li>
                            <li><i class="fas fa-circle text-xs mr-2 text-blue-400"></i>任务调度</li>
                            <li><i class="fas fa-circle text-xs mr-2 text-blue-400"></i>状态管理</li>
                        </ul>
                    </div>
                    
                    <!-- Distributed Transactions -->
                    <div class="bg-white p-6 rounded-xl shadow-sm border border-gray-100">
                        <div class="flex items-center mb-4">
                            <div class="bg-green-100 p-3 rounded-lg mr-4 text-green-600">
                                <i class="fas fa-random text-xl"></i>
                            </div>
                            <h4 class="text-xl font-bold text-gray-800">分布式事务</h4>
                        </div>
                        <p class="text-gray-700 mb-4">
                            涉及多个参与者的事务操作，保证事务的一致性和原子性。
                        </p>
                        <ul class="text-gray-700 text-sm space-y-2">
                            <li><i class="fas fa-circle text-xs mr-2 text-green-400"></i>两阶段提交(2PC)</li>
                            <li><i class="fas fa-circle text-xs mr-2 text-green-400"></i>三阶段提交(3PC)</li>
                            <li><i class="fas fa-circle text-xs mr-2 text-green-400"></i>补偿事务(Saga)</li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Summary Section -->
    <section class="py-16 px-4 bg-indigo-50">
        <div class="container mx-auto max-w-6xl">
            <div class="text-center mb-12">
                <h2 class="text-3xl font-bold mb-4 text-gray-800">架构选择指南</h2>
                <p class="text-xl text-gray-600 max-w-3xl mx-auto">根据业务需求选择合适的架构方案</p>
                <div class="w-24 h-1 bg-indigo-500 mx-auto mt-4"></div>
            </div>
            
            <div class="bg-white rounded-xl shadow-md overflow-hidden">
                <div class="grid grid-cols-1 md:grid-cols-2">
                    <!-- Microservices -->
                    <div class="p-8 border-b md:border-b-0 md:border-r border-gray-200">
                        <div class="flex items-center mb-6">
                            <div class="bg-blue-100 p-3 rounded-lg mr-4 text-blue-600">
                                <i class="fas fa-cubes text-2xl"></i>
                            </div>
                            <h3 class="text-2xl font-bold text-gray-800">微服务架构</h3>
                        </div>
                        <ul class="space-y-4 text-gray-700">
                            <li class="flex items-start">
                                <i class="fas fa-check text-blue-500 mt-1 mr-3"></i>
                                <span>适合大型复杂业务系统，需要快速迭代和持续交付</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check text-blue-500 mt-1 mr-3"></i>
                                <span>需要多个团队独立开发和部署不同功能模块</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check text-blue-500 mt-1 mr-3"></i>
                                <span>业务需求变化频繁，需要技术栈灵活性</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check text-blue-500 mt-1 mr-3"></i>
                                <span>需要精细化的扩展能力，不同组件可能有不同的负载需求</span>
                            </li>
                        </ul>
                    </div>
                    
                    <!-- Distributed -->
                    <div class="p-8">
                        <div class="flex items-center mb-6">
                            <div class="bg-purple-100 p-3 rounded-lg mr-4 text-purple-600">
                                <i class="fas fa-network-wired text-2xl"></i>
                            </div>
                            <h3 class="text-2xl font-bold text-gray-800">分布式系统</h3>
                        </div>
                        <ul class="space-y-4 text-gray-700">
                            <li class="flex items-start">
                                <i class="fas fa-check text-purple-500 mt-1 mr-3"></i>
                                <span>需要处理海量数据或高并发请求</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check text-purple-500 mt-1 mr-3"></i>
                                <span>系统需要高可用性和容错能力</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check text-purple-500 mt-1 mr-3"></i>
                                <span>业务需要跨地域部署和数据同步</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check text-purple-500 mt-1 mr-3"></i>
                                <span>需要利用多台计算机的协同计算能力</span>
                            </li>
                        </ul>
                    </div>
                </div>
                <div class="bg-gray-50 px-8 py-6 border-t border-gray-200">
                    <h4 class="text-lg font-semibold text-gray-800 mb-4">关键决策因素</h4>
                    <div class="grid grid-cols-1 md:grid-cols-3 gap-4">
                        <div class="bg-white p-4 rounded-lg shadow-xs">
                            <h5 class="font-medium text-gray-800 mb-2">团队规模</h5>
                            <p class="text-gray-600 text-sm">小型团队可能更适合单体或简单分布式，大型团队适合微服务</p>
                        </div>
                        <div class="bg-white p-4 rounded-lg shadow-xs">
                            <h5 class="font-medium text-gray-800 mb-2">业务复杂度</h5>
                            <p class="text-gray-600 text-sm">简单业务不需要微服务，复杂业务可能受益于微服务拆分</p>
                        </div>
                        <div class="bg-white p-4 rounded-lg shadow-xs">
                            <h5 class="font-medium text-gray-800 mb-2">基础设施</h5>
                            <p class="text-gray-600 text-sm">评估运维团队能力，微服务和分布式需要更强的运维支持</p>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Footer -->
    <footer class="bg-gray-900 text-gray-300 py-8 px-4">
        <div class="container mx-auto max-w-6xl">
            <div class="flex flex-col md:flex-row justify-between items-center">
                <div class="mb-4 md:mb-0">
                    <h3 class="text-xl font-semibold text-white mb-2">技术小馆</h3>
                    <p class="text-gray-400">探索技术前沿，分享架构智慧</p>
                </div>
                <div>
                    <a href="http://www.yuque.com/jtostring" class="text-gray-300 hover:text-white transition duration-300">
                        <i class="fas fa-book-open mr-2"></i>访问技术小馆
                    </a>
                </div>
            </div>
            <div class="border-t border-gray-800 mt-8 pt-8 text-center text-sm text-gray-500">
                &copy; 2023 技术小馆. 保留所有权利.
            </div>
        </div>
    </footer>

    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true,
                curve: 'basis'
            }
        });
        
        // 平滑滚动
        document.querySelectorAll('a[href^="#"]').forEach(anchor => {
            anchor.addEventListener('click', function (e) {
                e.preventDefault();
                document.querySelector(this.getAttribute('href')).scrollIntoView({
                    behavior: 'smooth'
                });
            });
        });
        
        // 卡片悬停效果
        const cards = document.querySelectorAll('.card-hover, .comparison-card');
        cards.forEach(card => {
            card.addEventListener('mouseenter', () => {
                card.style.transition = 'all 0.3s ease';
            });
        });
    </script>
</body>
</html>
```